﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Web.UI.Page;

using X.Common;

namespace E.Web.Teacher.interactive
{
    public partial class Reply : TeacherBasePage
    {
        public QandAModel model = new QandAModel();

        protected override void ShowPage()
        {
            int id = XRequest.GetInt("id", -1);

            if (ispost && id != -1)
            {
                string content = XRequest.GetString("ContentTxt");

                QandAModel model = new QandAModel();
                model.ID = id;
                model.UserID = -1;
                model.ParentID = id;
                model.TeacherID = teacherid;
                model.Content = content;
                model.AddDate = DateTime.Now;

                int rst = (new TeacherBLL()).ReplyQnA(model);

                if (rst > 0)
                {
                    ExecuteJS("alert('提交成功'); window.location = '/interactive/List.aspx';");
                }
                else
                {
                    Alert("提交失败，请稍后再试");
                }
            }
            else
            {
                if (id != -1)
                {
                    model = (new TeacherBLL()).GetQnAInfo(id);
                }
                else
                {
                    ExecuteJS("alert('服务器忙，请稍后再试'); history.back();");
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
